package com.pagoda.nerp.trade.service.impl;

import com.pagoda.nerp.trade.common.exception.AccountException;
import com.pagoda.nerp.trade.dao.AccUsersDao;
import com.pagoda.nerp.trade.entity.AccUsers;
import com.pagoda.nerp.trade.service.AccUsersService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * Created by Jungle on 2016/12/20.
 */
@Service
public class AccUsersServiceImpl implements AccUsersService {

    private static final Logger logger = LoggerFactory.getLogger(AccUsersServiceImpl.class);

    @Autowired
    private AccUsersDao accUsersDao;

    /**
     * 根据条件获取当前系统用户的基本信息
     * 功能：
     * 1、用来对用户进行账号密码校验
     * 2、用来获取用户的基本信息
     * @param condition
     * @return
     * @throws AccountException
     */
    @Override
    public AccUsers findAccUsersByCondition(Map condition) throws AccountException {
        AccUsers accUsers = accUsersDao.selectOneByCondition(condition);
        if(null == accUsers){
            throw new AccountException("当前会员信息不存在或者密码错误，查看详情失败");
        }
        return accUsers;
    }
}
